package com.example.config.swagger;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Author: jintao123
 * @Date: 2017/5/3 20:26
 * @Desc: Swagger 配置文件
 */
@Configuration
@EnableSwagger2
public class SwaggerConf {
    @Value("${swagger.contact}")
    private String contact;
    @Value("${swagger.title}")
    private String title;
    @Value("${swagger.description}")
    private String description;

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        ApiInfo apiInfo = new ApiInfo(title,//大标题
                description,//小标题
                "1.0",//版本
                "NO terms of service",
                contact,//作者
                "I_Know",//链接显示文字
                "http://blog.csdn.net/i____know"//网站链接
        );

        return apiInfo;
    }
}
